import {useIntersectionObserver} from '@vueuse/core'


export const lazyPlugin = {
  install(app){
  /// el: 指令绑定的哪个元素
  // binding: bingding.value 指令等于好后母按绑定的表达式值
  app.directive('img-lazy',{
    mounted(el , binding){
      const {stop} = useIntersectionObserver(
        el,
        ([{isIntersecting}]) => {
          console.log(isIntersecting)
          if(isIntersecting){
            //进入视口区域
            el.src = binding.value
            stop()
          }
        }
      )
    }
  })
  }
}





